﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization.Json;
using System.Text;
using System.IO;

namespace Luminji.Core.StringTool
{
    public class StreamConvertor
    {
        public MemoryStream StringToMemoryStream(string str)
        {
            using (MemoryStream stream = new MemoryStream(Encoding.UTF8.GetBytes(str)))
            {
                return stream;
            }
        }

        public string MemoryStreamToString(MemoryStream memoryStream)
        {
            try
            {
                return Encoding.UTF8.GetString(memoryStream.ToArray());
            }
            finally 
            {
                memoryStream.Dispose();
            }
        }
    }
}
